

**********************************************************************************************************************
**** Table A1. ITT Effects in Comparison to Basic Treatment – Excluding Outliers ************************************
**********************************************************************************************************************


use "$data/Non_payment_dataset_ready.dta" , clear

log using "$filepath/output_logs/table A1", replace


* Grubbs outlier test to determine outliers
preserve
keep if t==12 & itt!=.
keep customer itt maxpayment  
grubbs maxpayment, level(99.9) gen(out) // 99.9% ->  4050 -> additional 142 obs dropped
bys out: sum maxpayment 
restore


*********************************
**** Initial month (October) ****
*********************************

local controls "itt2 itt3 premeaninvoicew presumpaymentratiow preage_of_accountw preclosingbalancew prepaidcounttotal interviewerdummy* datedummy* schemedummynew*"

* Extensive Margin *
probit paidcount `controls' if t==14 & maxpayment<4050 , rob
margins, dydx(itt2 itt3) post


*Intensive Margin*
reg lnpayment `controls' if t==14 & maxpayment<4050, rob


*TWO PM*
preserve 
keep if t==14 & maxpayment<4050 
capture program drop Ey_boot
program define Ey_boot, eclass
twopm payment itt2 itt3 premeaninvoicew presumpaymentratiow preage_of_accountw preclosingbalancew prepaidcounttotal interviewerdummy* datedummy* schemedummynew*, firstpart(probit) secondpart(regress, log) vce(cluster customer)
margins, dydx(itt2 itt3) predict(duan) nose post
end
bootstrap _b, seed(3125) reps(1000): Ey_boot
estimates store W 
restore

** IHS payment **
reg asinhpayment `controls' if t==14 & maxpayment<4050 ,  vce(cluster customer)

sum  paidcount lnpayment payment asinhpayment if t==14 & itt==0 & maxpayment< 4350.33 // comparison values


*************************************
**** Medium term (November-June) ****
*************************************

local controls "itt2 itt3 i.t premeaninvoicew presumpaymentratiow preage_of_accountw preclosingbalancew prepaidcounttotal interviewerdummy* datedummy* schemedummynew*"

*midterm *
probit paidcount `controls' if t>=15 & t<=22 & maxpayment<4050, vce(cluster customer)
margins, dydx(itt2 itt3) post

*Intensive Margin*
reg lnpayment `controls' if t>=15 & t<=22 & maxpayment<4050, vce(cluster customer)

*TWO PM*
preserve 
keep if t>=15 & t<=22 & maxpayment<4050
capture program drop Ey_boot
program define Ey_boot, eclass
twopm payment itt2 itt3 i.t premeaninvoicew presumpaymentratiow preage_of_accountw preclosingbalancew prepaidcounttotal interviewerdummy* datedummy* schemedummynew* , firstpart(probit) secondpart(regress, log) vce(cluster customer)
margins, dydx(itt2 itt3) predict(duan) nose post
end
bootstrap _b, seed(3125) reps(1000): Ey_boot
restore

reg asinhpayment `controls' if t>=15 & t<=22 & maxpayment<4050, vce(cluster customer)

sum  paidcount lnpayment payment asinhpayment if t>=15 & t<=22 & itt==0 & maxpayment<4050 // comparison values

log close
